require.config({
	shim:{
        'calendar':{exports:'calendar'}
    },
    paths : {
        //"vue":"lib/vue",
        "jquery":"lib/jquery",
        "cmd":"cmd",
        "calendar":"lib/datepicker/WdatePicker",
    }
});

require(['jquery','cmd','calendar'],function($){

//get top menu
var token = detectToken();



$.vloading.show();
$.ajax({ 
    type:"post", 
    url:urls.smslogLists, 
    data: {token:token,pageNow:1,pageSize:20}, 
    dataType: 'json', 
    async : true,
    success:function(result){ 
        var msglogListHtml = '';
        $.vloading.remove();
        if(result.code=="1"){
            for(var i=0;i<result.data.records.length;i++){
                if(result.data.records[i].success_count==0){
                    msglogListHtml += '<div class="tableTReach clearfix">\n\
                      <div class="tablecommoncel-1 tableTBdpoint fl"><i class="xwl i-checkno"></i></div>\n\
                      <div class="tablecommoncel-2 tableTBdZH fl oellipsis">'+result.data.records[i].userName+'</div>\n\
                      <div class="tablecommoncel-3 tableTBdDTU fl"><input value="'+result.data.records[i].recieve_list+'" readonly="readonly"></div>\n\
                      <div class="tablecommoncel-4 tableTBdMK fl oellipsis"><input value="'+result.data.records[i].customer_name+'" readonly="readonly"></div>\n\
                      <div class="tablecommoncel-5 tableTBdFF fl">'+result.data.records[i].dtu_id+'</div>\n\
                      <div class="tablecommoncel-6 tableTBdIP fl oellipsis">'+result.data.records[i].msisdn+'</div>\n\
                      <div class="tablecommoncel-7 tableTBdMS fl"><input value="'+result.data.records[i].content+'" readonly="readonly"></div>\n\
                      <div class="tablecommoncel-8 tableTBdJG fl">失败</div>\n\
                      <div class="tablecommoncel-9 tableTBdSJ fl">'+result.data.records[i].create_date+'</div>\n\
                    </div>';
                }else{
                    msglogListHtml += '<div class="tableTReach clearfix">\n\
                      <div class="tablecommoncel-1 tableTBdpoint fl"><i class="xwl i-checkno"></i></div>\n\
                      <div class="tablecommoncel-2 tableTBdZH fl oellipsis">'+result.data.records[i].userName+'</div>\n\
                      <div class="tablecommoncel-3 tableTBdDTU fl"><input value="'+result.data.records[i].recieve_list+'" readonly="readonly"></div>\n\
                      <div class="tablecommoncel-4 tableTBdMK fl oellipsis"><input value="'+result.data.records[i].customer_name+'" readonly="readonly"></div>\n\
                      <div class="tablecommoncel-5 tableTBdFF fl">'+result.data.records[i].dtu_id+'</div>\n\
                      <div class="tablecommoncel-6 tableTBdIP fl oellipsis">'+result.data.records[i].msisdn+'</div>\n\
                      <div class="tablecommoncel-7 tableTBdMS fl"><input value="'+result.data.records[i].content+'" readonly="readonly"></div>\n\
                      <div class="tablecommoncel-8 tableTBdJG fl">成功</div>\n\
                      <div class="tablecommoncel-9 tableTBdSJ fl">'+result.data.records[i].create_date+'</div>\n\
                    </div>';
                }

            }
            $(".showtableContent").html(msglogListHtml);
            //总页数
            $(".allpagesNums").html(result.data.pageCount);
            //总记录数
            $(".allRecord").html(result.data.rowCount);
            pageNav.go(1,result.data.pageCount);
            pageNav.fn = function(p,pn){
                    if($("#timerfilterBtn").attr("data-coding")==0){
                        getMsglogListHtml(p);
                        return;
                    }
            };

        }else{
            $.flytip("服务器繁忙，请稍后再试");
        }
    } 
});


//默认加载短信记录列表
var getMsglogListHtml = function(curNums){
    var pageNow = curNums;
    var pageSize = 20;
    var customer_name = $("#eventDtuId").val();
    var recieve_list = $("#eventkehuName").val();
    var content = $("#sysManaMsgcontent").val();
    var success_count = $("#eventIsread").val();
    var createStartDate =$("#startDate").val();
    var createStartEnd = $("#endDate").val();
    $.vloading.show();
    $.ajax({ 
        type:"post", 
        url:urls.smslogLists, 
        data: {token:token,pageNow:pageNow,pageSize:pageSize,customer_name:customer_name,recieve_list:recieve_list,content:content,success_count:success_count,createStartDate:createStartDate,createStartEnd:createStartEnd}, 
        dataType: 'json', 
        async : true,
        success:function(result){ 
            var msglogListHtml = '';
            $.vloading.remove();
            if(result.code=="1"){
                for(var i=0;i<result.data.records.length;i++){
                    if(result.data.records[i].success_count==0){
                        msglogListHtml += '<div class="tableTReach clearfix">\n\
                          <div class="tablecommoncel-1 tableTBdpoint fl"><i class="xwl i-checkno"></i></div>\n\
                          <div class="tablecommoncel-2 tableTBdZH fl oellipsis">'+result.data.records[i].userName+'</div>\n\
                          <div class="tablecommoncel-3 tableTBdDTU fl"><input value="'+result.data.records[i].recieve_list+'" readonly="readonly"></div>\n\
                          <div class="tablecommoncel-4 tableTBdMK fl oellipsis"><input value="'+result.data.records[i].customer_name+'" readonly="readonly"></div>\n\
                          <div class="tablecommoncel-5 tableTBdFF fl">'+result.data.records[i].dtu_id+'</div>\n\
                          <div class="tablecommoncel-6 tableTBdIP fl oellipsis">'+result.data.records[i].msisdn+'</div>\n\
                          <div class="tablecommoncel-7 tableTBdMS fl"><input value="'+result.data.records[i].content+'" readonly="readonly"></div>\n\
                          <div class="tablecommoncel-8 tableTBdJG fl">失败</div>\n\
                          <div class="tablecommoncel-9 tableTBdSJ fl">'+result.data.records[i].create_date+'</div>\n\
                        </div>';
                    }else{
                        msglogListHtml += '<div class="tableTReach clearfix">\n\
                          <div class="tablecommoncel-1 tableTBdpoint fl"><i class="xwl i-checkno"></i></div>\n\
                          <div class="tablecommoncel-2 tableTBdZH fl oellipsis">'+result.data.records[i].userName+'</div>\n\
                          <div class="tablecommoncel-3 tableTBdDTU fl"><input value="'+result.data.records[i].recieve_list+'" readonly="readonly"></div>\n\
                          <div class="tablecommoncel-4 tableTBdMK fl oellipsis"><input value="'+result.data.records[i].customer_name+'" readonly="readonly"></div>\n\
                          <div class="tablecommoncel-5 tableTBdFF fl">'+result.data.records[i].dtu_id+'</div>\n\
                          <div class="tablecommoncel-6 tableTBdIP fl oellipsis">'+result.data.records[i].msisdn+'</div>\n\
                          <div class="tablecommoncel-7 tableTBdMS fl"><input value="'+result.data.records[i].content+'" readonly="readonly"></div>\n\
                          <div class="tablecommoncel-8 tableTBdJG fl">成功</div>\n\
                          <div class="tablecommoncel-9 tableTBdSJ fl">'+result.data.records[i].create_date+'</div>\n\
                        </div>';
                    }

                }
                $(".showtableContent").html(msglogListHtml);
                //总页数
                $(".allpagesNums").html(result.data.pageCount);
                //总记录数
                $(".allRecord").html(result.data.rowCount);


            }else{
                $.flytip("服务器繁忙，请稍后再试");
            }
        } 
    }); 

}
//点击查询
$("#timerfilterBtn").on("click",function(){
    $("#timerfilterBtn").attr("data-coding","1");
    //getMsglogListHtml(1);
    var pageNow = 1;
    var pageSize = 20;
    var customer_name = $("#eventDtuId").val();
    var recieve_list = $("#eventkehuName").val();
    var content = $("#sysManaMsgcontent").val();
    var success_count = $("#eventIsread").val();
    var createStartDate =$("#startDate").val();
    var createStartEnd = $("#endDate").val();
    $.vloading.show();
    $.ajax({ 
        type:"post", 
        url:urls.smslogLists, 
        data: {token:token,pageNow:pageNow,pageSize:pageSize,customer_name:customer_name,recieve_list:recieve_list,content:content,success_count:success_count,createStartDate:createStartDate,createStartEnd:createStartEnd}, 
        dataType: 'json', 
        async : true,
        success:function(result){ 
            var msglogListHtml = '';
            $.vloading.remove();
            if(result.code=="1"){
                if(result.data.records.length==0){
                   $('.showtableContent').html('<p class="txtc" style="padding:19px 0;font-size:16px;border-right:1px solid #e9e9e9;border-bottom:1px solid #e9e9e9;">暂无数据</p>'); 
                }else{
                    for(var i=0;i<result.data.records.length;i++){
                        if(result.data.records[i].success_count==0){
                            msglogListHtml += '<div class="tableTReach clearfix">\n\
                              <div class="tablecommoncel-1 tableTBdpoint fl"><i class="xwl i-checkno"></i></div>\n\
                              <div class="tablecommoncel-2 tableTBdZH fl oellipsis">'+result.data.records[i].userName+'</div>\n\
                              <div class="tablecommoncel-3 tableTBdDTU fl"><input value="'+result.data.records[i].recieve_list+'" readonly="readonly"></div>\n\
                              <div class="tablecommoncel-4 tableTBdMK fl oellipsis"><input value="'+result.data.records[i].customer_name+'" readonly="readonly"></div>\n\
                              <div class="tablecommoncel-5 tableTBdFF fl">'+result.data.records[i].dtu_id+'</div>\n\
                              <div class="tablecommoncel-6 tableTBdIP fl oellipsis">'+result.data.records[i].msisdn+'</div>\n\
                              <div class="tablecommoncel-7 tableTBdMS fl"><input value="'+result.data.records[i].content+'" readonly="readonly"></div>\n\
                              <div class="tablecommoncel-8 tableTBdJG fl">失败</div>\n\
                              <div class="tablecommoncel-9 tableTBdSJ fl">'+result.data.records[i].create_date+'</div>\n\
                            </div>';
                        }else{
                            msglogListHtml += '<div class="tableTReach clearfix">\n\
                              <div class="tablecommoncel-1 tableTBdpoint fl"><i class="xwl i-checkno"></i></div>\n\
                              <div class="tablecommoncel-2 tableTBdZH fl oellipsis">'+result.data.records[i].userName+'</div>\n\
                              <div class="tablecommoncel-3 tableTBdDTU fl"><input value="'+result.data.records[i].recieve_list+'" readonly="readonly"></div>\n\
                              <div class="tablecommoncel-4 tableTBdMK fl oellipsis"><input value="'+result.data.records[i].customer_name+'" readonly="readonly"></div>\n\
                              <div class="tablecommoncel-5 tableTBdFF fl">'+result.data.records[i].dtu_id+'</div>\n\
                              <div class="tablecommoncel-6 tableTBdIP fl oellipsis">'+result.data.records[i].msisdn+'</div>\n\
                              <div class="tablecommoncel-7 tableTBdMS fl"><input value="'+result.data.records[i].content+'" readonly="readonly"></div>\n\
                              <div class="tablecommoncel-8 tableTBdJG fl">成功</div>\n\
                              <div class="tablecommoncel-9 tableTBdSJ fl">'+result.data.records[i].create_date+'</div>\n\
                            </div>';
                        }

                    }
                    $(".showtableContent").html(msglogListHtml);
                    //总页数
                    $(".allpagesNums").html(result.data.pageCount);
                    //总记录数
                    $(".allRecord").html(result.data.rowCount);
                    pageNav.go(1,result.data.pageCount);
                    pageNav.fn = function(p,pn){
                            if($("#timerfilterBtn").attr("data-coding")==1){
                                getMsglogListHtml(p);
                                return;
                            }
                    };                    
                }


            }else{
                $.flytip("服务器繁忙，请稍后再试");
            }
        } 
    }); 
    












})

 









//个人中心下拉
$("#showmyAccountMenu").toggle(
    function(){$("#toggleshowmenu").show();},
    function(){$("#toggleshowmenu").hide();}
);

//$.flytip("zhowdom");$.vloading.show();$.vloading.remove();
getOnelayerMenu();
getTwolayerMenu(601,604);
$(".mianshowbpt-r a").eq(2).addClass("cur");
getThreelayerMenu(604);



//短息记录新增
$(".newAddBtns,.delBtns").on("click",function(){
  $.flytip("改功能暂未开放...");  
})
//短信记录删除（批量/单个）




//req.js end
})